﻿@using System.Text.Json.Serialization
@attribute [JSCustomElement]

@if (Model is not null)
{
    <MTabs @bind-Value="_tabValue" Class="mb-1">
        @foreach (var tab in Tabs)
        {
            <MTab Class="text-none">@tab</MTab>
        }
    </MTabs>

    <MTabsItems Value="_tabValue">
        @foreach (var tabItem in TabItems)
        {
            <MTabItem>
                <Markup Code="@tabItem.Code" Language="@tabItem.Lang"></Markup>
            </MTabItem>
        }
    </MTabsItems>
}

@code {

    [Parameter]
    public Dictionary<string, MarkupModel>? Model { get; set; }

    private StringNumber? _tabValue;

    private IEnumerable<string> Tabs => (Model ?? new()).Keys;

    private IEnumerable<MarkupModel> TabItems => (Model ?? new()).Values;

    public class MarkupModel
    {
        [JsonPropertyName("code")]
        public string? Code { get; set; }

        [JsonPropertyName("lang")]
        public string? Lang { get; set; }
    }

}
